package com.hippoDocker.configcilent.controller;

import com.hippoDocker.commons.entities.CommonResult;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName ConfigController
 * @Description TODO config配置中心读取配置
 * @Author hippoDocker
 * @Date 2022/6/28 19:27
 **/
@RestController
@RequestMapping("/config")
@RefreshScope
public class ConfigController {

    @Value("server.port")
    private String serverPort;

    @Value("${spring.datasource.username}")
    private String uname;

    @Value("${spring.datasource.password}")
    private String pwd;

    @Value("${spring.application.name}")
    private String appName;

    @GetMapping("/getconfig")
    public CommonResult getConfig(){
        return CommonResult.success("AplicationName:"+appName+"==========Port:"+serverPort+"==========userName："+uname+"==========password:"+pwd);
    }
}
